package top.zuli.package01.class13;

public class ThreadDemo62 {
    public static void main(String[] args) {
        Thread thread = new Thread(new Runnable3(),"线程1");
        Thread thread1 = new Thread(new Runnable4(),"线程2");
        thread.start();
        thread1.start();
    }
}
class Runnable3 implements Runnable{

    @Override
    public void run() {
        for (int i = 0; i <= 100; i++) {
            if (i%2==0){
                try {
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println(Thread.currentThread().getName()+":"+i);
            }
        }
    }
}
class Runnable4 implements Runnable{

    @Override
    public void run() {
        for (int i = 0; i <= 100; i++) {
            if (i%2!=0){
                try {
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println(Thread.currentThread().getName()+":"+i);
            }
        }
    }
}